<template>
  <div class="app-container home">
    <h1>当前学期：{{ currentSemester }}</h1>
    <!-- 下拉框1 周数-->
    <p>第几周：</p>
    <el-select v-model="selectedItem1" placeholder="请选择" style="width: 7vw;">
      <el-option
        v-for="item in options1"
        :key="item.value"
        :label="item.label"
        :value="item.value">
      </el-option>
    </el-select>
    <p>星期几：</p>
    <!-- 下拉框2 周几（哪一天） -->
    <el-select v-model="selectedItem2" placeholder="请选择" style="width: 7vw;">
      <el-option
        v-for="item in options2"
        :key="item.value"
        :label="item.label"
        :value="item.value">
      </el-option>
    </el-select>

    <!-- 提交按钮 -->
    <el-button type="primary" @click="handleSubmit" style="margin-left: 4vw;">搜索</el-button>
    <CourseCard :msg="msg" />
  </div>
</template>

<script>
import { getCourse } from '../api/lab';
import { getCurrent } from '../api/lab/semester';
import CourseCard from '../components/CourseCard/index.vue';
export default {
  name: "Index",
  components: {
    CourseCard
  },
  data() {
    return {
      // 版本号
      currentSemester: "3.8.6",
      msg: [{
        semester: 1,
        week: 1,
        weekNum: 1,
        labList: [
          {
            id: "732",
            labType: "软件实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          },
          {
            id: "734",
            labType: "软件实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          },
          {
            id: "734",
            labType: "软件实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          },
          {
            id: "734",
            labType: "软件实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          },
          {
            id: "734",
            labType: "软件实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          },
          {
            id: "734",
            labType: "软件实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          },
          {
            id: "734",
            labType: "软件实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          },
          {
            id: "734",
            labType: "软件实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          },
          {
            id: "734",
            labType: "软件实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          },
          {
            id: "734",
            labType: "软件实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          },
          {
            id: "734",
            labType: "软件实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          }
        ]
      }, {
        semester: 1,
        week: 2,
        weekNum: 1,
        labList: [
          {
            id: "732",
            labType: "计算机系统实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          },
          {
            id: "734",
            labType: "软件实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          }
        ]
      }, {
        semester: 1,
        week: 3,
        weekNum: 1,
        labList: [
          {
            id: "732",
            labType: "计算机系统实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          },
          {
            id: "734",
            labType: "软件实验室",
            courseList: [{
              courseNo: 1,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 2,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 3,
              courseName: "",
              courseHost: "",
              courseTeam: "",
              courseCover: ""
            }, {
              courseNo: 4,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 5,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }, {
              courseNo: 6,
              courseName: "汇编语言",
              courseHost: "张三",
              courseTeam: "21软件工程7班",
              courseCover: "5-12"
            }]
          }
        ]
      }
      ],
      // 下拉框1的选项（周数）
      options1: [
        { value: '1', label: '第一周' },
        { value: '2', label: '第二周' },
        { value: '3', label: '第三周' },
        { value: '4', label: '第四周' },
        { value: '5', label: '第五周' },
        { value: '6', label: '第六周' },
        { value: '7', label: '第七周' },
        { value: '8', label: '第八周' },
        { value: '9', label: '第九周' },
        { value: '10', label: '第十周' },
        { value: '11', label: '第十一周' },
        { value: '12', label: '第十二周' },
        { value: '13', label: '第十三周' },
        { value: '14', label: '第十四周' },
        { value: '15', label: '第十五周' },
        { value: '16', label: '第十六周' },
        { value: '17', label: '第十七周' },
        { value: '18', label: '第十八周' },

      ],
      // 下拉框2的选项（周几）
      options2: [
        { value: '1', label: '周一' },
        { value: '2', label: '周二' },
        { value: '3', label: '周三' },
        { value: '4', label: '周四' },
        { value: '5', label: '周五' }

      ],
      // 保存下拉框1选择的值
      selectedItem1: '1',
      // 保存下拉框2选择的值
      selectedItem2: '2'     
    };
  },
  methods: {
    // 提交按钮点击事件处理函数
    async handleSubmit() {
      // 输出选择的两个参数到控制台
      console.log('选择的参数1：', this.selectedItem1);
      console.log('选择的参数2：', this.selectedItem2);
      await this.getCourse(this.selectedItem1,this.selectedItem2)
    },
    goTarget(href) {
      window.open(href, "_blank");
    },
    getCurrent() {
      getCurrent().then(res => {
        console.log(res)
        this.currentSemester = res.data.term
      })
    },
    //week 第几周
    //dayOfWeek 星期几
    async getCourse(week, dayOfWeek) {
        try {
        const response = await getCourse(week, dayOfWeek);
        console.log(response.data);
        this.msg = response.data; // 更新 msg 数据
      } catch (error) {
        console.error('获取课程信息失败:', error);
      }
    }

  },
  async mounted () {
    this.getCurrent();

    await this.getCourse(this.selectedItem1,this.selectedItem2);

  },
};
</script>

<style scoped lang="scss">
.home {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;

  //margin-right: 6vw;
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }

  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }

  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans",
  "Helvetica Neue",
  Helvetica,
  Arial,
  sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 2vh;
    margin-left: 4vw;
    font-size: 1vw;
    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>
